package six_Bio;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) {
//        method_1();
        method_2();
    }

    private static void method_2() {
        try {
            ServerSocket ss = new ServerSocket(9999);
            while (true) {
                Socket s = ss.accept();
                new ServerThreadReader(s).start();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void method_1() {
        try {
            ServerSocket ss = new ServerSocket(9999);
            Socket s = ss.accept();
            BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
            String line;
            while ((line = br.readLine()) != null) {
                System.out.println("receive from Client: " + line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
